import java.util.Random;

public class YootDice {
	public static final int UP = 0;
	public static final int DOWN = 1;
	public static final int OUT = 2;
	
	public static final int DO = 1;
	public static final int GAE = 2;
	public static final int GUL = 3;
	public static final int YOOT = 4;
	public static final int MO = 5;
	
	private int[] stick; 
	
	public YootDice()
	{
		int[] stick = new int[4];	//Four sticks used in Yootnori
	}
	
	public int[] throwStick()
	{
		Random rand = new Random();
		for(int i=0;i<4;i++)
		{
			int temp=rand.nextInt()%10;
			if(temp<=4)	//50%
				stick[i]=UP;
			else if(temp>4&&temp<=8)	//40%
				stick[i]=DOWN;
			else	//10%
				stick[i]=OUT;
		}
		return stick;
	}
	
	public int[] getStick()
	{
		return stick;
	}
	
	public int getResult()
	{
		int count=0;
		boolean fall=false;
		boolean back=false;
		for(int i=0;i<4;i++)
		{
			if(stick[i]==UP)
			{
				if(stick[0]==UP)
					back=true;
				count++;
			}
			else if(stick[i]==DOWN);
			else
				fall=true;
		}
		switch (count)
		{
		case 0:
			return YOOT;
		case 1:
			return GUL;
		case 2:
			return GAE;
		case 3:
			if(back)
				return -DO;
			return DO;
		case 4:
			return MO;
		default:
			return 0;
		}
	}
}
